package day0926_3;

import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
class Test{
    public static void main(String[] args) {
        TreeSet<Teacher>  set=new TreeSet(  new MyC() );//3.1.
        Teacher  t1=new Teacher();   t1.height=200;//3.2.
        Teacher  t2=new Teacher();   t2.height=190;//3.2.
        set.add(t1);   set.add(t2);//3.2.
        Iterator ite=set.iterator();//A.
        while(ite.hasNext()){//B.
            Teacher tea=(Teacher)ite.next();//C.
            System.out.println(tea.height);
        }
    }
}





public class MyC  implements Comparator<Teacher> {
    public int compare(Teacher o1, Teacher o2) {
        return   (int)(o1.height-o2.height);
    }
}














